<template>
	<view>
		<u-navbar :is-back="false" title="　" :border-bottom="false">
			<view class="u-flex u-row-right" style="width: 100%;">
				<view class="camera u-flex u-row-center">
				</view>
			</view>
		</u-navbar>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="u-m-r-10">
				<u-avatar :src="form.imageUrl" size="140"></u-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20" v-model="form.userName">{{form.userName}}</view>
				<view class="u-font-14 u-tips-color" v-model="form.jobNumber">员工工号:{{form.jobNumber}}</view>
			</view>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="account" title="个人信息" @click="toPersonInfo"></u-cell-item>
				<u-cell-item icon="error-circle" title="异常报警" @click="toDealError" v-if="form.roleId == 28 || form.roleId == 27 || form.roleId == 31  || form.roleId == 36"></u-cell-item>
				<u-cell-item icon="order" title="绑定工位" @click="toBindPage" v-if="form.roleId == 33 || form.roleId == 34"></u-cell-item>
				<u-cell-item icon="error-circle" title="质量检查" @click="toScanCheck" v-if="form.roleId == 33 || form.roleId == 34"></u-cell-item>
				<u-cell-item icon="file-text" title="指定线下维修" @click="downMaintenance" v-if="form.roleId == 35 || form.roleId == 36"></u-cell-item>
				<u-cell-item icon="file-text" title="维修记录" @click="toFeedBackForm"></u-cell-item>
				<u-cell-item icon="file-text" title="维修确认" @click="tomaintenanceSubmit" v-if="form.roleId == 33 || form.roleId == 34"></u-cell-item>
				<u-cell-item icon="file-text" title="设备点检" @click="toSpotCheckList('设备点检')"></u-cell-item>
				<u-cell-item icon="file-text" title="设备保养" @click="toSpotCheckList('设备保养')"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
import { accessPersonInfo } from '../utils/index.js'
	export default {
		data() {
			return {
				form: {
					userName:'',					//用户姓名
					jobNumber:'',					//员工工号
					imageUrl:'',						//用户头像
					user: uni.getStorageSync('user')
				}
			}
		},
		// 进入home页面即获取该用户信息
		onLoad() {
			this.getUserInfo()
		},
		methods: {
			toSpotCheckList(name){
		    	uni.navigateTo({
		    		url:'../../../publicPage/spotCheckList?name=' + name
		    	})
		    },
			tomaintenanceSubmit(){
				uni.navigateTo({
					url:'./maintenanceSubmit'
				})
			},
			toFeedBackForm(){
				uni.navigateTo({
					url:'./feedBackForm'
				})
			},
			// 个人信息页面跳转
			toPersonInfo(){
				uni.navigateTo({
					url:'./personInfo'
				})
			},
			// 获取用户信息函数
			async getUserInfo(){
				const {data} = await accessPersonInfo()
				this.form = Object.assign({},data.data)
				uni.setNavigationBarTitle({
					title: this.form.roleId == 2?'员工管理员':
					this.form.roleId == 4?'计划人员':
					this.form.roleId == 12?'总监':
					this.form.roleId == 14?'超级管理员':
					this.form.roleId == 19?'生产':
					this.form.roleId == 25?'数控机台调度员':
					this.form.roleId == 27?'工艺经理':
					this.form.roleId == 28?'设备人员':
					this.form.roleId == 29?'计划总监':
					this.form.roleId == 30?'工艺总监':
					this.form.roleId == 31?'物流人员':
					this.form.roleId == 32?'数控计划人员':
					this.form.roleId == 33?'EMS总装车间QC':
					this.form.roleId == 34?'EMS总装车间OBA':
					this.form.roleId == 35?'工艺管理员(EMS)':
					this.form.roleId == 36?'工艺经理(EMS)':'暂无角色'
				});
			},
			// 跳转异常报警
			toDealError() {
				if(this.form.roleId == 28 || this.form.roleId == 27 || this.form.roleId == 31 || this.form.roleId == 36){
					uni.navigateTo({
						url:'../pagesA/publicPage/getErrorList?roleId=' + this.form.roleId
					})
				}
			},
			// 跳转质检
			toScanCheck() {
				if(this.form.roleId == 33 || this.form.roleId == 34){
					uni.navigateTo({
						url:'../publicPage/scanCheck?roleId=' + this.form.roleId
					})
				}
			},
			// 绑定工位
			toBindPage(){
				uni.navigateTo({
					url:'../publicPage/bindPage'
				})
			},
			downMaintenance(){
				uni.navigateTo({
					url:"../pages/QC/childPage/downMaintenance?feedbackPlanNo=" + ''
						+ '&deviceBarcode=' + ''
						+ '&feedbackWorkOrderNo=' + ''
						+ '&feedbackOrderType=' + ''
						+ '&feedbackProcessOrder=' + ''
						+ '&processName=' + ''
						+ '&feedbackName=' + ''
						+ '&isCraft=' + true
				})
			},
		}
	}
</script>

<style lang="scss">
page{
	background-color: #ededed;
}

.camera{
	width: 54px;
	height: 44px;
	
	&:active{
		background-color: #ededed;
	}
}
.user-box{
	background-color: #fff;
}
</style>